package com.ruoyi.back.controller

import cn.hutool.core.bean.BeanUtil
import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.ruoyi.app.common.Data
import com.ruoyi.app.common.Ok
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.ChannelManager
import com.ruoyi.back.domain.Template
import com.ruoyi.back.domain.dto.TemplateSearchDto
import com.ruoyi.back.service.ChannelManagerService
import com.ruoyi.back.service.TemplateService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiModel
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("system/template")
@Api(tags = ["视频模板&图片模板"])
class TemplateController {

    @Autowired
    private lateinit var templateService: TemplateService

    @Autowired
    private lateinit var channelManagerService: ChannelManagerService

    @ApiOperation("保存模板")
    @PostMapping("save")
    fun saveTemplate(@RequestBody template: Template): Data<Boolean> = templateService.saveTemplate(template)

    @GetMapping("getChannelList")
    @ApiOperation("获取渠道列表")
    fun getChannelList(): PageData<ChannelManager> =
        channelManagerService.page(Page(1, 100)).pageInfo()

    @ApiOperation("模板分页")
    @GetMapping("page")
    fun templatePage(templateSearchDto: TemplateSearchDto): PageData<Template> = templateService.templatePage(templateSearchDto)

    @ApiOperation("移除模板")
    @GetMapping("remove/{ids}")
    fun removeTemplate(@PathVariable ids: String): Data<Boolean> = templateService.removeTemplate(ids)
}